home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 47
/
Amiga Format AFCD47 (Issue 131, Xmas 1999).iso
/
-serious-
/
misc
/
fiasco_2.22
/
arexx
/
converttolistview.frx
< prev
next >
Wrap
Text File
|
1999-10-17
|
4KB
|
184 lines
/* ConvertToListview.frx
* Converts a certain number of simple fields to one listview field
* Copyright © 1997 Nils Bandener
* $VER: ConvertToListview_frx 6.2 (6.10.97)
*/
/* Usage:
*
* The IDs of the simple fields must end with numbers, counting from
* 1 to a given value. The listview field, to which the fields will
* be converted to, must be already created before executing this
* script.
*
* Call:
*
* rx ConvertToListview.rexx <SimpleID> <Number> <ListviewID>
*
* SimpleID: The ID of the simple fields. If your simple fields
* are named "Field_1", "Field_2", "Field_3", etc.,
* you have to give "Field_" here.
* Number: The number of simple fields. If you have fields
* from "Field_1" to "Field_25", you have to give
* 25 here.
* ListviewID: The ID of the listview, in which the data will be
* put.
*/
Parse Arg SimpleID FieldNum ListviewID
Options Results
scriptname = "Convert To Listview"
Options Results
/*
* If not called from Fiasco, try to address the active
* Fiasco project
*/
if ~abbrev(address(), "FIASCO.") then
do
ports = show("Ports")
do i = 1 to words(ports)
if abbrev(word(ports, i), "FIASCO.") then
do
Address Value word(ports, i)
GetAttr Project Name Active ARexx
Address Value Result
break
end
end
end
fiasco_port = address()
Signal on Syntax
Signal on Halt
Signal on Break_C
Signal on Failure
LockGUI
if SimpleID = "" then
do
RequestString '"" Text "Please enter the ID of the*nsimple fields to be converted:*n(If these fields are named Field_1, Field_2, ..., enter Field_)"'
if rc ~= 0 then call bail_out
SimpleID = Result
end
if FieldNum = "" | FieldNum = 0 then
do
RequestNumber '"1" Text "Please enter the number of*nsimple fields with the ID*n' || SimpleID || '"'
if rc ~= 0 then call bail_out
FieldNum = Result
end
if ListviewID = "" then
do
RequestField 'Text "Please select the listview field,*ninto which the data will be put"'
if rc ~= 0 then call bail_out
ListviewID = Result
end
CountRecords Var recnum
/*
* Go through all records
*/
do i = 1 to recnum
do k = 1 to fieldnum
GetField '"' || SimpleID || k || '"' Record i
cont = result
/*
* Only add a new entry, if everything is
* Ok and cont is not empty
*/
if rc = 0 & cont ~= "" then
do
AddLVFieldEntry '"' || ListviewID || '"' Record i
/*
* Read the number of entries
* in the listview field
*/
GetField '"' || ListviewID || '"' Record i ListEntryCount Var entnum
SetField '"' || ListviewID || '"' Record i ListEntry entnum cont
end
end
end
bail_out:
Address Value fiasco_port
UnlockGUI
ResetStatus
exit
syntax:
failure:
if show("Ports", fiasco_port) then
do
Interpret Address fiasco_port
RequestChoice '"Error ' || rc || ' in line ' || sigl || ':*n' || errortext(rc) || '" "Cancel" Title "' || scriptname || '"'
end
else
do
say "Error" rc "in line" sigl ":" errortext(rc)
say "Enter to continue"
pull dummy
end
call bail_out
halt:
break_c:
if show("Ports", fiasco_port) then
do
Interpret Address fiasco_port
RequestChoice '"Script Abort Requested" "Abort Script" Title "' || scriptname || '"'
if result = 0 then return
end
else
do
say "*** Break"
say "Enter to continue"
pull dummy
end
call bail_out